import Vue from 'vue'

import Cookies from 'js-cookie'

import 'normalize.css/normalize.css' // a modern alternative to CSS resets

import Element from 'element-ui'
import './assets/styles/element-variables.scss'
// import 'element-ui/lib/theme-chalk/display.css'

import '@/assets/styles/index.scss' // global css
import '@/assets/styles/ruoyi.scss' // ruoyi css
import '@/assets/styles/iconfont/iconfont.css'
import '@/assets/styles/tabler/tabler.css'

import '@/assets/styles/theme-default.css'
import '@/assets/styles/common.css'
import '@/assets/styles/r_setting.scss'

import '@/assets/styles/theme/default/core.css'

import '@/assets/styles/theme/dark_theme.scss'


import cm from '@/utils/demo.js'

import 'remixicon/fonts/remixicon.css'

Vue.prototype.$cm=cm.cuscommon;
// import '@/assets/styles/theme/dark/core.dark.scss'
// import '@/assets/styles/theme/dark/theme_default_dark.scss'

import App from './App'
import store from './store'
import router from './router'
import permission from './directive/permission'

import './assets/icons' // icon
import './permission' // permission control
import dataV from '@jiaminghi/data-view'
import { borderBox1 } from '@jiaminghi/data-view'
import { getDicts } from "@/api/system/dict/data";
import { getConfigKey } from "@/api/system/config";
import moment from 'moment/moment';
import { parseTime, resetForm, addDateRange, selectDictLabel, download, handleTree } from "@/utils/ruoyi";
import Pagination from "@/components/Pagination";
import * as socketApi from "./utils/socket"

import i18n from './i18n/index'

import VueClipboard from 'vue-clipboard2';
VueClipboard.config.autoSetContainer = true;
Vue.use(VueClipboard)

// 全局方法挂载
Vue.prototype.getDicts = getDicts
Vue.prototype.getConfigKey = getConfigKey
Vue.prototype.parseTime = parseTime
Vue.prototype.resetForm = resetForm
Vue.prototype.addDateRange = addDateRange
Vue.prototype.selectDictLabel = selectDictLabel
Vue.prototype.download = download
Vue.prototype.handleTree = handleTree

Vue.prototype.msgSuccess = function (msg) {
  this.$message({ showClose: true, message: msg, type: "success" });
}

Vue.prototype.msgError = function (msg) {
  this.$message({ showClose: true, message: msg, type: "error" });
}

Vue.prototype.msgInfo = function (msg) {
  this.$message.info(msg);
}

Vue.prototype.socketApi = socketApi
// 全局组件挂载
Vue.component('Pagination', Pagination)

Vue.use(permission)
Vue.use(dataV)

/**
 * If you don't want to use mock-server
 * you want to use MockJs for mock api
 * you can execute: mockXHR()
 *
 * Currently MockJs will be used in the production environment,
 * please remove it before going online! ! !
 */

Vue.use(Element, {
  i18n: (key, value) => i18n.t(key, value),
  size: Cookies.get('size') || 'medium' // set element-ui default size
})

Vue.config.productionTip = false
Vue.filter('moment', function (value, formatString) {
  if (value == undefined) {
    return '-';
  }
  formatString = formatString || 'YYYY-MM-DD HH:mm';
  return moment(value).format(formatString); // value可以是普通日期 20170723
  // return moment.unix(value).format(formatString); // 这是时间戳转时间
});
Vue.filter('currency', function (cellValue) {
  if (cellValue) {
    return Number(cellValue)
      .toFixed(2)
      .replace(/(\d)(?=(\d{3})+\.)/g, ($0, $1) => {
        return $1 + ",";
      })
      .replace(/\.$/, "");
  } else {
    return '0.00'
  }
});
Vue.filter('intFillZero', function (val, len) {
  if (val == null || val === '') {
    return '-'
  }
  if (len == null) {
    len = 8
  }
  let s = val.toFixed(0).toString()
  let zero = ''
  for (let i = s.length; i < len; i++) {
    zero += '0'
  }
  return zero + s
});

new Vue({
  el: '#app',
  i18n,
  router,
  store,
  render: h => h(App)
})
